//
//  SettingTableViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/18.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "SettingTableViewCell.h"

@interface SettingTableViewCell ()

@property (strong, nonatomic) UILabel *titleL;
@property (strong, nonatomic) UIImageView *arrowIV;
@property (strong, nonatomic) UILabel *cacheL;
@property (strong, nonatomic) UIImageView *phoneL;
@property (strong, nonatomic) UILabel *workTimeL;

@end

@implementation SettingTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self.contentView addSubview:self.titleL];
        [self.contentView addSubview:self.arrowIV];
        [self.contentView addSubview:self.cacheL];
        [self.contentView addSubview:self.phoneL];
        [self.contentView addSubview:self.workTimeL];

    }
    
    return self;
}

- (void)setCachesSize:(NSString *)cachesSize {
    
    _cachesSize = cachesSize;
    
    self.cacheL.text = cachesSize;
    
}

- (void)setDict:(NSDictionary *)dict {
    
    _dict = dict;
    
    self.titleL.text = dict[@"title"];
    
    if (self.type == 2) {
        
        self.cacheL.hidden = NO;
    
    }else if (self.type == 3) {
        
        self.phoneL.hidden = NO;
        self.workTimeL.hidden = NO;
    
    }else {
        
        self.arrowIV.hidden = NO;
    }
    
}


- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(weakSelf.contentView.mas_left).with.offset(jisuan(40));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
    }];
    [self.arrowIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(40));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        
        make.width.mas_equalTo(jisuan(12));
        make.height.mas_equalTo(jisuan(20));
    }];
    [self.cacheL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(40));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);

    }];
    [self.phoneL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.contentView.mas_right).with.offset(-jisuan(40));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        
        make.width.mas_equalTo(jisuan(38));
        make.height.mas_equalTo(jisuan(30));
    }];
    [self.workTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(weakSelf.phoneL.mas_left).with.offset(-jisuan(12));
        make.centerY.mas_equalTo(weakSelf.contentView.mas_centerY);
        
    }];
}

#pragma mark -lazy
- (UILabel *)titleL {
    
    if (!_titleL) {
        
        _titleL = [[UILabel alloc] init];
        _titleL.textColor = Color333333;
        _titleL.font = Font(24);
        _titleL.textAlignment = NSTextAlignmentLeft;
        
    }
    return _titleL;
}
- (UIImageView *)arrowIV {

    if (!_arrowIV) {
        
        _arrowIV = [[UIImageView alloc] init];
        _arrowIV.contentMode = UIViewContentModeScaleAspectFit;
        _arrowIV.image = [UIImage imageNamed:@"settingRigthArrowBG"];
        _arrowIV.hidden = YES;
    }
    return _arrowIV;
}

- (UILabel *)cacheL {
    
    if (!_cacheL) {
        
        _cacheL = [[UILabel alloc] init];
        _cacheL.textColor = Color9b9b9b;
        _cacheL.font = Font(24);
        _cacheL.textAlignment = NSTextAlignmentRight;
//        _cacheL.text = @"10.34MB";
        _cacheL.hidden = YES;
        
    }
    return _cacheL;
}

- (UILabel *)workTimeL {
    
    if (!_workTimeL) {
        
        _workTimeL = [[UILabel alloc] init];
        _workTimeL.textColor = Color9b9b9b;
        _workTimeL.font = Font(24);
        _workTimeL.textAlignment = NSTextAlignmentRight;
        _workTimeL.text = @"工作时间：9:00～17:30";
        
        _workTimeL.hidden = YES;
        
    }
    return _workTimeL;
}
- (UIImageView *)phoneL {
    
    if (!_phoneL) {
        
        _phoneL = [[UIImageView alloc] init];
        _phoneL.contentMode = UIViewContentModeScaleAspectFit;
        _phoneL.image = [UIImage imageNamed:@"settingPhoneBG"];
        
        _phoneL.hidden = YES;
    }
    return _phoneL;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
